<?php


namespace app\admin\controller;

use app\admin\model\Admin as AdminModel;
use think\Controller;
use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\exception\DbException;
use think\exception\PDOException;


class Admin extends Controller
{
//    查询密码
    public function selectPassword($name){
        try {
            $data = AdminModel::where("admin_name", $name)->findOrEmpty();
            /*一定要看文档！*/
            return $data->toArray();
//            return json($data);
        } catch (DataNotFoundException $e) {
        } catch (ModelNotFoundException $e) {
        } catch (DbException $e) {

        }
    }

//  修改密码
    public function  updatePass($newPass){
        try {
            return Db::table('b_admin')
                ->where("admin_id", 1)
                ->setField('admin_password',$newPass);
        } catch (PDOException $e) {
        } catch (Exception $e) {
        }
    }
}